package com.yuanhua.xcxmng.wechat.controller;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

import com.yuanhua.xcxmng.wechat.entity.WechatResult;
import com.yuanhua.xcxmng.wechat.exception.SessionException;

/**
 * @author hzy24985
 * @version $Id: GlobalExcptionHandler, v 0.1 2018/8/7 下午3:48 hzy24985 Exp $
 */
@ControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(value = { SessionException.class })
    public WechatResult<String> sessionExceptions(final SessionException ex) {
        return new WechatResult<>("", ex.getErrorCode(), "sessionId获取失败" + ex.getThreeSession());
    }

    @ExceptionHandler(value = { Exception.class })
    public WechatResult<String> handleOtherExceptions(final Exception ex) {
        return new WechatResult<>("", -1, ex.getMessage());
    }
}
